package com.woldier.check.common.restTemplate;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.woldier.check.common.hadoop.FileStatuses;
import org.springframework.stereotype.Component;

@Component
public class CommonRequest {

    public static FileStatuses JSONObject2FileStatuses(JSONObject object){
    return JSON.parseObject(object.getJSONObject("FileStatuses").toString(), FileStatuses.class);
    }

    /**
     * 生成url,不带repository路径
     * @param username
     * @param option
     * @return
     */
    public static String generateUrl(String url,String username,String option){
        String Url = url+"/"+username+ "?op="+option;
        return Url;
    }
    /**
     * 生成url,带repository路径
     * @param username
     * @param option
     * @return
     */
    public static String generateUrl(String url,String username,String  repository,String option){
        String Url = url+"/"+username+"/"+repository+"?op="+option;
        return Url;
    }
}
